package edu.fiu.cis.personalize.server.berkDB.serializers;

import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

import edu.fiu.cis.personalize.server.graph.User;
import edu.fiu.cis.personalize.server.graph.store.CountingConcMap;
import edu.fiu.cis.personalize.server.graph.store.NodeEdges;

public class UserSerializer extends NodeSerializer<User> {

	private CountingConcMapSerializer ccmSerializer = new CountingConcMapSerializer();

	@Override
	public void objectToEntry(User node, TupleOutput to) {
		super.objectToEntry(node, to);
		// write the rest of the data
		ccmSerializer.objectToEntry(node.getClicksDocument(), to);
		ccmSerializer.objectToEntry(node.getSubmitsQuery(), to);

	}

	@Override
	protected User process(TupleInput ti, int id, String uname,
			NodeEdges nodeEdges, double rank) {
		CountingConcMap  cd = (CountingConcMap)ccmSerializer.entryToObject(ti);
		CountingConcMap  sq = (CountingConcMap)ccmSerializer.entryToObject(ti);
		return User.create(id, uname, nodeEdges, rank,cd,sq);
	}

}
